package fr.cie.blog.services.parsingservice;

import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import com.thoughtworks.xstream.XStream;

import fr.cie.blog.beans.Country;

/**
 * Parse the list of Country in XML format.
 * 
 * @author Jee3
 * 
 */
public class CountryParser {

	/**
	 * Parse a new list of Countries.
	 * 
	 * @param url
	 *            the path where the file is
	 * @return the updated list of country
	 */
	@SuppressWarnings("unchecked")
	public final List<Country> updateCountryList(final URL url) {

		List<Country> countryList = new ArrayList<Country>();
		final XStream xstream = new XStream();

		xstream.alias("country", Country.class);

		countryList = (List<Country>) xstream.fromXML(url);

		return countryList;
	}
}